package com.example.lib_mvi.base

import androidx.lifecycle.ViewModel
import com.nezha.lib_mvi.IIntent
import com.nezha.lib_mvi.IViewModel
import kotlinx.coroutines.channels.Channel

/**
 * @author yaotianxue
 * @description  BaseViewModel封装
 * @date 2025/2/24
 */
abstract class BaseViewMode<I: IIntent>:ViewModel(), IViewModel<I> {
    protected val _intents = Channel<I> { Channel.UNLIMITED }
    override val intents: Channel<I> //重写父类的
        get() =  _intents

    init {
        handleIntent()
    }

    /**`
     * 根据不同的意图处理行为
     */
    abstract fun handleIntent()
}